package com.jason.weibosender;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;

import org.pushingpixels.substance.api.skin.SubstanceGraphiteGlassLookAndFeel;

import weibo4j.util.WeiboConfig;

import com.jason.weibosender.ui.ClientFrame;
import com.jason.weibosender.ui.CodeFrame;
import com.jason.weibosender.util.TokenCheckerHelper;
import com.sun.corba.se.spi.orbutil.threadpool.ThreadPool;

public class Main implements Runnable{
	public static void main(String[] args) {
		EventQueue.invokeLater(new Main());
	}
	
	@Override
	public void run() {
		JFrame.setDefaultLookAndFeelDecorated(true);
		JDialog.setDefaultLookAndFeelDecorated(true);
		try {
			UIManager.setLookAndFeel(new SubstanceGraphiteGlassLookAndFeel());
		} catch (Exception e) {
			// Do nothing
		}
		String accessToken = WeiboConfig
		.getValue("accessToken");
		if(accessToken != null && accessToken.length() > 0){
			new Thread(new CatchService()).start();
			long size = TokenCheckerHelper.checkTokenAvaliableTime(accessToken);
			if(size != -1){
				new ClientFrame(accessToken, size);
			}
		} else {
			new CodeFrame();
		}
	}
}
